home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power CD-ROM!! 8
/
Power CD-ROM 8.iso
/
prgmming
/
pmd110
/
xms.pas
< prev
Wrap
Pascal/Delphi Source File
|
1994-11-13
|
4KB
|
86 lines
(* This file was mangled by Mangler 1.35 (c) Copyright 1993-1994 by Berend de Boer *)
{ Created : 1994-09-08 (c) Copyright 1994 by Berend de Boer
XMS access unit created from ObjMemory.
Last changes :
}
{$IFNDEF MsDos}
Error
{$ENDIF}
{$F+,O+,X+}
unit XMS;
interface
type
TXMSHandle = word;
type
TXMSParameterBlock = record
Count : longint; {* should be even! *}
SourceHandle : TXMSHandle;
SourceOffs : longint;
DestHandle : TXMSHandle;
DestOffs : longint;
end;
type
TXMSHandleInfo = record
Locked : Boolean;
HandlesAvailable : byte;
BlockSize : word;
end;
const
XMSInstalled:Boolean = FALSE; {* set by xms_init *}
XMSVersion:word = 0; {* set by xms_init *}
XMSResult:byte = 0; {* status if xms function returned false *}
XMSEntry:pointer = nil;
procedure xms_init;
function xms_allocate(var Handle : TXMSHandle; Size : longint) : Boolean;
function xms_dispose(Handle : TXMSHandle) : Boolean;
procedure xms_get_driver_address;
function xms_get_handle_info(Handle : TXMSHandle; var HandleInfo : TXMSHandleInfo) : Boolean;
procedure xms_get_version;
function xms_maxavail : word;
function xms_memavail : word;
function xms_move_emb(SourceHandle : TXMSHandle; SourceOffs : longint;
DestHandle : TXMSHandle; DestOffs, Count : longint) : Boolean;
function xms_present : Boolean;
IMPLEMENTATION {$IFDEF Debug}USES ASSERTIONS ;{$ENDIF}PROCEDURE XMS_INIT ;BEGIN IF NOT XMS_PRESENT THEN EXIT ;
XMS_GET_DRIVER_ADDRESS ;XMS_GET_VERSION ;IF XMSVERSION < $300 THEN EXIT ;XMSINSTALLED := TRUE ;END ;
FUNCTION XMS_ALLOCATE (VAR HANDLE:TXMSHANDLE;SIZE:LONGINT):BOOLEAN ;ASSEMBLER;ASM {} MOV AX , WORD PTR SIZE{}
MOV DX , WORD PTR SIZE+ 2 {} MOV CX , 400h {} DIV CX {} CMP DX , 0 {} JE @1 {} INC AX {} @1 : {} MOV DX , AX {}
MOV AH , 09h {} CALL XMSENTRY{} MOV XMSRESULT, BL {} CMP AX , 0 {} JNE @ok {} XOR DX , DX {} @ok : {} LES DI , HANDLE{}
MOV ES : [ DI ] , DX {} END;FUNCTION XMS_DISPOSE (HANDLE:TXMSHANDLE):BOOLEAN ;ASSEMBLER;ASM {} MOV DX , HANDLE{}
MOV AH , 0ah {} CALL XMSENTRY{} MOV XMSRESULT, BL {} END;PROCEDURE XMS_GET_DRIVER_ADDRESS ;ASSEMBLER;ASM {}
MOV AX , 4310h {} INT 2fh {} MOV WORD PTR XMSENTRY, BX {} MOV WORD PTR XMSENTRY+ 2 , ES {} END;
FUNCTION XMS_GET_HANDLE_INFO (HANDLE:TXMSHANDLE;VAR HANDLEINFO:TXMSHANDLEINFO):BOOLEAN ;ASSEMBLER;ASM {}
MOV DX , HANDLE{} MOV AH , 0eh {} CALL XMSENTRY{} MOV XMSRESULT, BL {} MOV WORD PTR HANDLEINFO, BX {}
MOV WORD PTR HANDLEINFO+ 2 , DX {} END;PROCEDURE XMS_GET_VERSION ;ASSEMBLER;ASM {} MOV AH , 0 {} CALL XMSENTRY{}
MOV XMSVERSION, AX {} END;FUNCTION XMS_MOVE_EMB (SOURCEHANDLE:TXMSHANDLE;SOURCEOFFS:LONGINT;DESTHANDLE:TXMSHANDLE;
DESTOFFS,COUNT:LONGINT):BOOLEAN ;ASSEMBLER;VAR OIOIIIOII0:TXMSPARAMETERBLOCK;ASM {} MOV AX , WORD PTR COUNT{}
MOV WORD PTR OIOIIIOII0.COUNT, AX {} MOV AX , WORD PTR COUNT+ 2 {} MOV WORD PTR OIOIIIOII0.COUNT+ 2 , AX {}
MOV AX , SOURCEHANDLE{} MOV OIOIIIOII0.SOURCEHANDLE, AX {} MOV AX , WORD PTR SOURCEOFFS{}
MOV WORD PTR OIOIIIOII0.SOURCEOFFS, AX {} MOV AX , WORD PTR SOURCEOFFS+ 2 {}
MOV WORD PTR OIOIIIOII0.SOURCEOFFS+ 2 , AX {} MOV AX , DESTHANDLE{} MOV OIOIIIOII0.DESTHANDLE, AX {}
MOV AX , WORD PTR DESTOFFS{} MOV WORD PTR OIOIIIOII0.DESTOFFS, AX {} MOV AX , WORD PTR DESTOFFS+ 2 {}
MOV WORD PTR OIOIIIOII0.DESTOFFS+ 2 , AX {} MOV AH , 0bh {} LEA DI , XMSENTRY{} MOV BX , DS {} MOV ES , BX {} PUSH DS {}
LEA SI , OIOIIIOII0{} MOV BX , SS {} MOV DS , BX {} CALL DWORD PTR ES : [ DI ] {} POP DS {} MOV XMSRESULT, BL {} END;
FUNCTION XMS_MAXAVAIL :WORD ;ASSEMBLER;ASM {} MOV AH , 08h {} CALL XMSENTRY{} MOV XMSRESULT, BL {} END;
FUNCTION XMS_MEMAVAIL :WORD ;ASSEMBLER;ASM {} MOV AH , 08h {} CALL XMSENTRY{} MOV XMSRESULT, BL {} MOV AX , DX {} END;
FUNCTION XMS_PRESENT :BOOLEAN ;ASSEMBLER;ASM {} MOV AX , 4300h {} INT 2fh {} CMP AL , 80h {} JNE @error {} MOV AL , 01 {}
JMP @end {} @error : {} XOR AL , AL {} @end : {} END;END .